<template>
  <div id="app-other-file">
    <div class="one-block-1">
      <h3 class="title">其他</h3>
      <div class="operate-wrapper">
        <a-space>
          <a-button type="primary">其他</a-button>
          <span>
            <a-select
              :style="{ width: '160px' }"
              placeholder="请选择"
              :trigger-props="{ autoFitPopupMinWidth: true }"
            >
              <a-option>用户日志</a-option>
              <a-option>操作日志</a-option>
            </a-select>
            <a-button style="position: relative; top: 2.5px; left: -2px"
              ><icon-search
            /></a-button>
          </span>
        </a-space>
      </div>
    </div>
    <div class="one-block-2">
      <p>其他</p>
    </div>
  </div>
</template>
<script>
import { ipcApiRoute } from '@/utils/ipcMainApi'
import { ipc } from '@/utils/ipcRenderer'
import storage from 'store2'

export default {
  data() {
    return {
      columns: [
        {
          title: '序',
          dataIndex: '1',
          align: 'center',
          width: 50,
        },
        {
          title: '关键词  [ 多个词使用"-"隔开，例子：A-B-C ]',
          dataIndex: '2',
        },
        {
          title: '回复内容',
          dataIndex: '3',
        },
      ],
      tabList: [
        {
          key: '1',
          1: '1',
          2: '拍了-已拍',
          3: '好的，谢谢粉丝宝宝们的支持！',
        },
        {
          key: '2',
          1: '2',
          2: '怎么拍-怎么买',
          3: '好的，谢谢粉丝宝宝们的支持！',
        },
      ],
    }
  },
  mounted() {
    // this.getHost()
  },
  methods: {
    getHost() {
      ipc.invoke(ipcApiRoute.checkHttpServer, {}).then((r) => {
        if (r.enable) {
          this.servicAddress = r.server
          storage.set('httpServiceConfig', r)

          // url转换
          const host = r.server || 'http://localhost:7071'
          let uri = ipcApiRoute.uploadFile
          let url = uri.split('.').join('/')
          this.action_url = host + '/' + url
        }
      })
    },
    openDirectry(id) {
      ipc.invoke(ipcApiRoute.openDirectory, { id: id }).then((res) => {
        //console.log('res:', res)
      })
    },
    selectDir() {
      ipc.invoke(ipcApiRoute.selectFolder, '').then((r) => {
        this.dir_path = r
        this.$message.info(r)
      })
    },
    messageShow() {
      ipc.invoke(ipcApiRoute.messageShow, '').then((r) => {
        this.$message.info(r)
      })
    },
    messageShowConfirm() {
      ipc.invoke(ipcApiRoute.messageShowConfirm, '').then((r) => {
        this.$message.info(r)
      })
    },
    handleFileChange(info) {
      console.log('handleFileChange-----')
      if (this.action_url == '') {
        this.$message.error('http服务未开启')
        return
      }
      const status = info.file.status
      if (status !== 'uploading') {
        console.log(info.file)
      }
      if (status === 'done') {
        const uploadRes = info.file.response
        console.log('uploadRes:', uploadRes)
        if (uploadRes.code !== 'success') {
          this.$message.error(`file upload failed ${uploadRes.code} .`)
          return false
        }
        this.num++
        const picInfo = uploadRes.data
        picInfo.id = this.num
        picInfo.imageUrlText = 'image url'
        this.image_info.push(picInfo)
        this.$message.success(`${info.file.name} file uploaded successfully.`)
      } else if (status === 'error') {
        this.$message.error(`${info.file.name} file upload failed.`)
      }
    },
  },
}
</script>
<style lang="less" scoped>
#app-other-file {
  width: 100%;
  height: calc(100% - 100px);
  padding: 0px 20px;
  text-align: left;
  box-sizing: border-box;
  .one-block-1 {
    font-size: 16px;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .one-block-2 {
    padding: 0 10px;
    margin-top: 10px;
    height: 100%;
    border: 1px solid #eee;
    box-sizing: border-box;
    color: #00ff00;
    line-height: 20px;
  }
}
</style>
